﻿using System;

namespace ParboiledSharp.parboiled.rules
{
    class DebugPrintAction : Rule
    {
        private readonly string _message;
        private readonly bool _newLine;
        public DebugPrintAction(string message, bool newLine)
        {
            _message = message;
            _newLine = newLine;
        }

        internal override bool Execute(dataobjects.Context context)
        {
            if (_newLine)
            {
                Console.Out.WriteLine(_message);
            }
            else
            {
                Console.Out.Write(_message);
            }
            return true;
        }
    }
}
